﻿
Partial Class store_paperbacks
    Inherits CSearchPage

#Region "Data"
    Private m_products As CProductList
    Public ReadOnly Property [Products]() As CProductList
        Get
            If IsNothing(m_products) Then
                Dim temp As New CProductList(CProduct.Cache.Active.Paperbacks)
                Dim temp2 As New CProductList(temp.Count)
                For Each i As CProduct In temp
                    If i.ProductName.StartsWith("Activating") OrElse i.ProductName.StartsWith("Deliverance") OrElse i.ProductName.StartsWith("Exercising") Then
                        temp2.Add(i)
                    End If
                Next
                temp2 = temp2.SortBy("ProductName")
                For Each i As CProduct In temp
                    If Not temp2.Contains(i) Then temp2.Add(i)
                Next
                m_products = temp2 'CProduct.Cache.Active.Paperbacks
            End If
            Return m_products
        End Get
    End Property
    Protected Overrides ReadOnly Property TypeId As EProductType
        Get
            Return EProductType.Paperback
        End Get
    End Property
#End Region

#Region "Menu"
    Protected Overrides ReadOnly Property TopPanel As System.Web.UI.WebControls.PlaceHolder
        Get
            Return plhTopLinks
        End Get
    End Property
    Protected Overrides ReadOnly Property SubPanel As System.Web.UI.WebControls.PlaceHolder
        Get
            Return plhSubLinks
        End Get
    End Property
#End Region

#Region "Event Handlers - Page"
    Protected Overrides Sub PageInit()
        'Dropdowns
        With Request.FilePath.ToLower
            If .Contains("/store/") OrElse .Contains("/mobile/") OrElse .Contains("books") Then Response.RedirectPermanent(CSitemap.Paperbacks(Search, SpeakerId))
        End With

        lnkAmazon.NavigateUrl = CSitemap.External_Amazon

        'Search state (from querystring)
        'txtSearch.Text = Me.Search

        lnkDonate.NavigateUrl = CSitemap.External_Donations
    End Sub
    Protected Overrides Sub PagePreRender()
        'Paging and display
        For Each i As CProduct In Products
            UCCreatespace(plh).Display(i, False)
        Next
    End Sub
#End Region

#Region "Event Handlers - Form"
#End Region

#Region "User Controls"
    Private Shared Function UCCreatespace(ByVal target As Control) As store_UCCreatespace
        Dim ctrl As Control = target.Page.LoadControl(CSitemap.Store_UCCreatespace)
        target.Controls.Add(ctrl)
        Return CType(ctrl, store_UCCreatespace)
    End Function
#End Region

End Class

